<!--
#html
#file test_otu_count_display.html

__author__ = "Jesse Stombaugh"
__copyright__ = "Copyright 2011, The QIIME Project" #consider project name
__credits__ = ["Jesse Stombaugh"] #remember to add yourself
__license__ = "GPL"
__version__ = "1.9.1-dev"
__maintainer__ = "Jesse Stombaugh"
__email__ = "jesse.stombaugh@colorado.edu"

from otu_count_display: row_max,col_max,row_sums,col_sums,filter_by_otu_count
-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                      "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		  <script src="http://code.jquery.com/jquery-latest.js"></script>
		  <link rel="stylesheet" href="http://github.com/jquery/qunit/raw/master/qunit/qunit.css" type="text/css" media="screen" />
		<script type="text/javascript" src="http://github.com/jquery/qunit/raw/master/qunit/qunit.js"></script>


			
		<script>
			var OTU_table=new Array();
			OTU_table[0]=new Array();
			OTU_table[0][0]='#OTU';
			OTU_table[0][1]='OTU1';
			OTU_table[0][2]='OTU2';
			OTU_table[0][3]='OTU3';
			OTU_table[1]=new Array();
			OTU_table[1][0]='Sample1';
			OTU_table[1][1]=1;
			OTU_table[1][2]=1;
			OTU_table[1][3]=1;
			OTU_table[2]=new Array();
			OTU_table[2][0]='Sample2';
			OTU_table[2][1]=5;
			OTU_table[2][2]=5;
			OTU_table[2][3]=5;
			OTU_table[3]=new Array();
			OTU_table[3][0]='Sample3';
			OTU_table[3][1]=10;
			OTU_table[3][2]=10;
			OTU_table[3][3]=10;
			OTU_table[4]=new Array();
			OTU_table[4][0]='Consensus';
			OTU_table[4][1]='Bacteria';
			OTU_table[4][2]='Bacteria; Firmicutes';
			OTU_table[4][3]='Bacteria; Bacteroidetes';
			var tran_otu_table=new Array();
			tran_otu_table[0]=new Array();
			tran_otu_table[0][0]='Consensus';
			tran_otu_table[0][1]='Sample1';
			tran_otu_table[0][2]='Sample2';
			tran_otu_table[0][3]='Sample3';
			tran_otu_table[0][4]='#OTU';
			tran_otu_table[1]=new Array();
			tran_otu_table[1][0]='Bacteria';
			tran_otu_table[1][1]=1;
			tran_otu_table[1][2]=5;
			tran_otu_table[1][3]=10;
			tran_otu_table[1][4]='OTU1';
			tran_otu_table[2]=new Array();
			tran_otu_table[2][0]='Bacteria; Firmicutes';
			tran_otu_table[2][1]=1;
			tran_otu_table[2][2]=5;
			tran_otu_table[2][3]=10;
			tran_otu_table[2][4]='OTU2';
			tran_otu_table[3]=new Array();
			tran_otu_table[3][0]='Bacteria; Bacteroidetes';
			tran_otu_table[3][1]=1;
			tran_otu_table[3][2]=5;
			tran_otu_table[3][3]=10;
			tran_otu_table[3][4]='OTU3';



			$(document).ready(function(){
				test("test_row_max", function() {
					var otu_counts1=OTU_table;
					var exp_row_max=new Array();
					exp_row_max[0]=0;
					exp_row_max[1]=1;
					exp_row_max[2]=5;
					exp_row_max[3]=10;
					var num_cols=4;
					var num_rows=4;
					var obs=get_row_max(otu_counts1,num_cols,num_rows);
					
					same(obs,exp_row_max, 
						 "Pass in array and get back array");
				});

				test("test_col_max", function() {
					var otu_counts2=OTU_table;
					var exp_col_max=new Array();
					exp_col_max[0]=0;
					exp_col_max[1]=10;
					exp_col_max[2]=10;
					exp_col_max[3]=10;
					var num_cols=4;
					var num_rows=4;
					var obs=get_col_max(otu_counts2,num_cols,num_rows);
					
					same(obs,exp_col_max, 
						 "Pass in array and get back array");
				});

				test("test_row_sums", function() {
					var otu_counts3=OTU_table;
					var exp_row_sums=new Array();
					exp_row_sums[0]=0;
					exp_row_sums[1]=3;
					exp_row_sums[2]=15;
					exp_row_sums[3]=30;
					var num_cols=4;
					var num_rows=4;
					var obs=get_row_sums(otu_counts3,num_cols,num_rows);
					
					same(obs,exp_row_sums, 
						 "Pass in array and get back array");
				});

				test("test_col_sums", function() {
					var otu_counts4=OTU_table;
					var exp_col_sums=new Array();
					exp_col_sums[0]=0;
					exp_col_sums[1]=16;
					exp_col_sums[2]=16;
					exp_col_sums[3]=16;
					var num_cols=4;
					var num_rows=4;
					var obs=get_col_sums(otu_counts4,num_cols, num_rows);
					
					same(obs,exp_col_sums, 
						 "Pass in array and get back array");
				});

				test("test_filter_by_otu_count", function() {
					var otu_counts5=OTU_table;
				 	var exp_otu_table=new Array();
					exp_otu_table[0]=new Array();
					exp_otu_table[0][0]='#OTU';
					exp_otu_table[1]=new Array();
					exp_otu_table[1][0]='Sample1';
					exp_otu_table[2]=new Array();
					exp_otu_table[2][0]='Sample2';
					exp_otu_table[3]=new Array();
					exp_otu_table[3][0]='Sample3';
					exp_otu_table[4]=new Array();
					exp_otu_table[4][0]='Consensus';
					var otu_cutoff='16';
			
					var obs=filter_by_otu_count(otu_counts5,otu_cutoff);
												
					same(obs,exp_otu_table, 
						 "Pass in array and get back array");
				});
				
				test("test_sort_and_comp_row_headers", function() {

					var test_otu_table=new Array();
					test_otu_table[0]=new Array();
					test_otu_table[0][0]='Sample3';
					test_otu_table[1]=new Array();
					test_otu_table[1][0]='Sample2';
					test_otu_table[2]=new Array();
					test_otu_table[2][0]='Sample1';
					
					var exp_otu_table=new Array();
					exp_otu_table[0]=new Array();
					exp_otu_table[0][0]='Sample1';
					exp_otu_table[1]=new Array();
					exp_otu_table[1][0]='Sample2';
					exp_otu_table[2]=new Array();
					exp_otu_table[2][0]='Sample3';
		
					var obs=test_otu_table.sort(comp_row_headers);
					//Cannot use the word Compare
					same(obs,exp_otu_table, 
						 "Pass in array and get back array");
				});
				
				test("test_create_mouseover", function() {
					var otu_counts6=OTU_table;
					var row=1;
					var col=1;
					var row_sum=5;
					var col_sum=5;
					var taxonomy=0;
					var lineage=OTU_table.length-1;
					var exp_mouseover_str="return overlib(\"<p><b>OTU: OTU1</b><br>";
					exp_mouseover_str+="1/5 (20.00%) Sequences<br><br>";
					exp_mouseover_str+="<b>SampleID: Sample1</b><br>1/5 (20.00%)";
					exp_mouseover_str+=" Displayed<br><br><b>Lineage: <br>";
					exp_mouseover_str+="<a href='http://www.google.com/";
					exp_mouseover_str+="search?q=Bacteria' target='_blank'>";
					exp_mouseover_str+="Bacteria</a></b></p>\",";
					exp_mouseover_str+="STICKY,MOUSEOFF,RIGHT);";
					var obs=create_mouseover(otu_counts6,row,col,row_sum,
											 col_sum,lineage,taxonomy);
					
					equals(obs,exp_mouseover_str, 
						   "Pass in variables and get back a mouseover string");
				});
				
				test("test_transpose_otu_table", function() {
					var otu_counts7=OTU_table;
					var exp_otu_table=new Array();
					exp_otu_table[0]=new Array();
					exp_otu_table[0][0]='Consensus';
					exp_otu_table[0][1]='Sample1';
					exp_otu_table[0][2]='Sample2';
					exp_otu_table[0][3]='Sample3';
					exp_otu_table[0][4]='#OTU';
					exp_otu_table[1]=new Array();
					exp_otu_table[1][0]='Bacteria';
					exp_otu_table[1][1]=1;
					exp_otu_table[1][2]=5;
					exp_otu_table[1][3]=10;
					exp_otu_table[1][4]='OTU1';
					exp_otu_table[2]=new Array();
					exp_otu_table[2][0]='Bacteria; Firmicutes';
					exp_otu_table[2][1]=1;
					exp_otu_table[2][2]=5;
					exp_otu_table[2][3]=10;
					exp_otu_table[2][4]='OTU2';
					exp_otu_table[3]=new Array();
					exp_otu_table[3][0]='Bacteria; Bacteroidetes';
					exp_otu_table[3][1]=1;
					exp_otu_table[3][2]=5;
					exp_otu_table[3][3]=10;
					exp_otu_table[3][4]='OTU3';
					var otu_cutoff='0';
					var lineage=0;
			
					var obs=transpose_otu_table(otu_counts7,otu_cutoff);
					
					same(obs,exp_otu_table, 
						   "Pass in variables and get back a mouseover string");
				});
				
				test("test_sort_by_taxonomy", function() {
					var otu_counts9=OTU_table;
					var exp_otu_table=new Array();
					exp_otu_table[0]=new Array();
					exp_otu_table[0][0]='Consensus';
					exp_otu_table[0][1]='Sample1';
					exp_otu_table[0][2]='Sample2';
					exp_otu_table[0][3]='Sample3';
					exp_otu_table[0][4]='#OTU';
					exp_otu_table[1]=new Array();
					exp_otu_table[1][0]='Bacteria';
					exp_otu_table[1][1]=1;
					exp_otu_table[1][2]=5;
					exp_otu_table[1][3]=10;
					exp_otu_table[1][4]='OTU1';
					exp_otu_table[2]=new Array();
					exp_otu_table[2][0]='Bacteria; Bacteroidetes';
					exp_otu_table[2][1]=1;
					exp_otu_table[2][2]=5;
					exp_otu_table[2][3]=10;
					exp_otu_table[2][4]='OTU3';
					exp_otu_table[3]=new Array();
					exp_otu_table[3][0]='Bacteria; Firmicutes';
					exp_otu_table[3][1]=1;
					exp_otu_table[3][2]=5;
					exp_otu_table[3][3]=10;
					exp_otu_table[3][4]='OTU2';

					var obs=sort_by_taxonomy(tran_otu_table);

					same(obs,exp_otu_table, 
						   "Pass in variables and get back a mouseover string");
				});
				 
			});
		</script>
		<script language="javascript" 
			src="../js/otu_count_display.js"></script>
	</head>
	<body>
		<h1 id="qunit-header">QUnit example</h1>
	 	<h2 id="qunit-banner"></h2>
	 	<h2 id="qunit-userAgent"></h2>
	 	<ol id="qunit-tests"></ol>
	</body>

</html>

